#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, a[N], sum;

int main()
{    
    cin >> n;
    for(int i = 1;i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    
    int t = 0, l = 1, r = 1, ans = 0;
    while(r <= n)
    {
        t += a[r];
        while(2 * t > sum) t -= a[l ++];
        ans = max(ans, t);
        r ++;
    }
    cout << ans << endl;
    return 0;
}